Thread Treemenu Admin Script: funzt nich... (13 answers)
Opened by FlorianL at 2007-06-08 10:13

FlorianL
 2007-06-08 10:13
#77379 #77379
User since
2007-05-18
142 Artikel
BenutzerIn
[default_avatar]
Moin zusammen :)

Und zwar bastel ich gerade eine administrationsoberfläche für ein javascript-treemenu (www.treemenu.net )

ich bekomm leider keinen fehler raus, kann also nicht sagen wo ich den fehler hab...

Problem ist einfach das die files nicht angelegt werden, ich denke daher das die variablen aus dem formular nicht richtig übergeben werden!?!

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#!/usr/bin/perl
#
# Treeview-Script by F.Luettgens
###
use strict;
use CGI;

my $nodefile = 'nodes.js';                      # Use absolute Path!
chomp((my $goto) = $ENV{"QUERY_STRING"});
#my $cgi = __FILE__ =~ m/.*$/;
my $cgi = "tree.cgi";
my $confquery = new CGI;
my @configs = $confquery->param;
my $newlink = new CGI;
my @entries = $newlink->param;


sub showconfig {
       open(NODES,$nodefile);
       my @scriptfile = <NODES>;
       close(NODES);
       print ("Treeview Konfiguration\n");
       print ("<br><hr/><br><pre>\n");
       print ("@scriptfile\n");
       print ("</pre>\n\n");
}

sub new {
       print ("<a href=\"./$cgi?newkat\">Neue Kategorie hinzufuegen</a>  (Nicht fertig)<br>\n");
       print ("<a href=\"./$cgi?newlink\">Neuen Link hinzufuegen</a><br><br>\n");
    print ("<a href=\"javascript:history.go(-1)\">Back</a>");
}

sub newlink {
       print("<form id=\"newlink\" name=\"newlink\" action=\"$cgi?savelink\" method=\"get\">\n");
       print("Bezeichner: <input name=\"newlink_name\" value=\"z.B Software\" maxlength=\"36\"/><br/>\n");
       print("Link: <input name=\"newlink_link\" value=\"z.B software.html\" maxlength=\"36\"/><br/>\n");
       print("Position: <input name=\"newlink_posi\" value=\"1,5\" maxlength=\"3\"/> (z.B 1,5 fuer Kategorie 1, Position 5)<br/>\n");
       print("Target-Frame: <input name=\"newlink_frame\" value=\"_right\" maxlength=\"36\"/><br/>\n");
    print("<input type=\"submit\" value=\"Speichern\" name=\"save\"/><br/>\n");
       print("</form><br><br>\n\n");
}

sub savelink {
       my $newlink_name = $newlink->param('newlink_name');
       my $newlink_link = $newlink->param('newlink_link');
       my $newlink_posi = $newlink->param('newlink_posi');
       (my $kategorie, my $sub_kategorie) = split(/\,/, $newlink_posi);
       my $newlink_frame = $newlink->param('newlink_frame');
       open(NEWNODE,">>.nodes.dat");
       print NEWNODE ("aux$kategorie = gLnk\(\"Rh\"\, \"$newlink_frame\"\, \"$newlink_link\"\)\)");
       close (NEWNODE);
       rebuild();
}

sub config {
       print("<form id=\"config\" name=\"config\" action=\"$cgi?saveconfig\" method=\"get\">\n");
       print("<input type=\"radio\" value=\"1\" name=\"buildall\"/>\n");
       print("<input type=\"radio\" value=\"0\" name=\"buildall\" checked/>  Tree komplett bauen oder erst auf Abruf? (Standart: 0)<br/>\n");
       print("<input type=\"radio\" value=\"1\" name=\"highlight\"/>\n");
       print("<input type=\"radio\" value=\"0\" name=\"highlight\" checked/>  Text hervorheben?<br/>\n");
       print("<input name=\"highlight_color\" value=\"blue\" maxlength=\"8\"/>  Highlight Schrift-Farbe (z.B white oder #FFFFFF)<br/>\n");
       print("<input name=\"highlight_bg\" value=\"white\" maxlength=\"8\"/>  Highlight Hintergrund-Farbe (z.B white oder #FFFFFF)<br/>\n");
       print("<input name=\"iconpath\" value=\"icons/\" maxlength=\"36\"/>  Pfad zum Icons Verzeichniss<br/>\n");
       print("<input type=\"radio\" value=\"1\" name=\"preservestate\" checked/>\n");
       print("<input type=\"radio\" value=\"0\" name=\"preservestate\"/>  Speichern des Trees per Cookie?<br/>\n");
       print("<input type=\"radio\" value=\"1\" name=\"startallopen\"/>\n");
       print("<input type=\"radio\" value=\"0\" name=\"startallopen\" checked/>  Alle Nodes ausgeklappt starten?<br/>\n");
       print("<input type=\"radio\" value=\"1\" name=\"useframes\"/>\n");
       print("<input type=\"radio\" value=\"0\" name=\"useframes\" checked/>  Frames nutzen?<br/>\n");
       print("<input type=\"radio\" value=\"1\" name=\"useicons\" checked/>\n");
       print("<input type=\"radio\" value=\"0\" name=\"useicons\"/>  Icons nutzen?<br/>\n");
       print("<input type=\"radio\" value=\"1\" name=\"usetextlinks\" checked/>\n");
       print("<input type=\"radio\" value=\"0\" name=\"usetextlinks\"/>  Text links nutzen? <br/>\n");
       print("<input type=\"radio\" value=\"1\" name=\"wraptext\"/>\n");
       print("<input type=\"radio\" value=\"0\" name=\"wraptext\" checked/>  Zeilenumbruch?<br/>\n");
       print("<input name=\"comment\" value=\"Kommentar\" maxlength=\"32\"/>  Kommentar<br/>\n");
       print("<input type=\"submit\" value=\"Speichern\" name=\"save\"/><br/>\n");
       print("</form><br><br>\n\n");
}

sub saveconfig {
       my $use_buildall = $confquery->param('buildall');
       my $use_highlight = $confquery->param('highlight');
       my $highlightcolor = $confquery->param('highlight_color');
       my $highlight_bg = $confquery->param('highlight_bg');
       my $iconpath = $confquery->param('iconpath');
       my $use_preserved = $confquery->param('preservedstate');
       my $use_startallopen = $confquery->param('startallopen');
       my $use_frames = $confquery->param('useframes');
       my $use_icons = $confquery->param('useicons');
       my $use_textlinks = $confquery->param('usetextlinks');
       my $use_wraptext = $confquery->param('wraptext');
       my $comment = $confquery->param('comment');
       open(CONFIG_HEAD,">.config.dat");
    if ($use_buildall eq '0') {
           print CONFIG_HEAD ("BUILDALL = 0\n")
    } elsif ($use_buildall eq '1') {
        print CONFIG_HEAD ("BUILDALL = 1\n")
    }
    if ($use_highlight eq '0') {
               print CONFIG_HEAD ("HIGHLIGHT = 0\n")
       } elsif ($use_highlight eq '1') {
               print CONFIG_HEAD ("HIGHLIGHT = 1\n")
       }
       if ($use_preserved eq '0') {
               print CONFIG_HEAD ("PRESERVESTATE = 0\n")
       } elsif ($use_preserved eq '1') {
               print CONFIG_HEAD ("PRESERVESTATE = 1\n")
       }
       if ($use_startallopen eq '0') {
               print CONFIG_HEAD ("STARTALLOPEN = 0\n")
       } elsif ($use_startallopen eq '1') {
               print CONFIG_HEAD ("STARTALLOPEN = 1\n")
       }
       if ($use_frames eq '0') {
               print CONFIG_HEAD ("USEFRAMES = 0\n")
       } elsif ($use_frames eq '1') {
               print CONFIG_HEAD ("USEFRAMES = 1\n")
       }
       if ($use_icons eq '0') {
               print CONFIG_HEAD ("USEICONS = 0\n")
       } elsif ($use_icons eq '1') {
               print CONFIG_HEAD ("USEICONS = 1\n")
       }
       if ($use_textlinks eq '0') {
               print CONFIG_HEAD ("USETEXTLINKS = 0\n")
       } elsif ($use_textlinks eq '1') {
               print CONFIG_HEAD ("USETEXTLINKS = 1\n")
       }
       if ($use_wraptext eq '0') {
               print CONFIG_HEAD ("WRAPTEXT = 0\n")
       } elsif ($use_wraptext eq '1') {
               print CONFIG_HEAD ("WRAPTEXT = 1\n")
       }
    print CONFIG_HEAD ("HIGHLIGHT_COLOR = $highlightcolor\n");
    print CONFIG_HEAD ("HIGHLIGHT_BG =  $highlight_bg\n");
    print CONFIG_HEAD ("ICONPATH = $iconpath\n");
    print CONFIG_HEAD ("\# $comment\n");
       close(CONFIG_HEAD);
       rebuild();
}

sub rebuild {
       open(CONFIG_HEAD,".config.dat");
       my @header = <CONFIG_HEAD>;
       close(CONFIG_HEAD);
       open(NEWNODES,".nodes.dat");
       my @entries = <NEWNODES>;
       close(NEWNODES);
       open(FINAL_CONFIG,">$nodefile");
       print FINAL_CONFIG @header;
       print FINAL_CONFIG @entries;
       close (FINAL_CONFIG);
}

print ("Content-Type: text/html\n\n");
print ("<HTML>\n");
print ("<HEAD>\n");
print ("<TITLE>Treeview Builder Script</TITLE>\n");
print ("<meta name=\"AUTHOR\" content=\"SWD\">\n");
print ("</HEAD>\n");
print ("<BODY>\n");
print ("<!-- Script by F.Luettgens for SWD-Ag 2007 -->\n");
print ("<BR><BR>\n");

if (($goto) eq 'show') {
       showconfig();
       print ("<a href=\"javascript:history.go(-1)\">Back</a>");
} elsif (($goto) eq 'newlink') {
       newlink();
       print ("<a href=\"javascript:history.go(-1)\">Back</a>");
} elsif (($goto) eq 'config') {
       config();
       print ("<a href=\"javascript:history.go(-1)\">Back</a>");
} elsif (($goto) eq 'saveconfig') {
       saveconfig();
       print ("<a href=\"javascript:history.go(-1)\">Back</a>");
} elsif (($goto) eq 'safelink') {
       safelink();
       print ("<a href=\"javascript:history.go(-1)\">Back</a>");
} elsif (($goto) eq 'new') {
       new();
} else {
       print ("<a href=\"./$cgi?show\">Config anzeigen</a>");
       print ("<BR>\n");
       print ("<a href=\"./$cgi?config\">Treeview anpassen</a>");
       print ("<BR>\n");
       print ("<a href=\"./$cgi?new\">Einen neuen Eintrag hinzufuegen</a>");
       print ("<BR>\n");
}

print ("</BODY>\n");
print ("</HTML>\n");


edit: ich hab testweise mal den pfad zur zu beschreibenden datei auf /tmp gelegt und || die "datei xy" hinzugefügt, ebenfalls kein fehler...\n\n

<!--EDIT|FlorianL|1181283510-->

View full thread Treemenu Admin Script: funzt nich...